# $Id$
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Alexander Rødseth <rodseth@gmail.com>
# Contributor: Marcin "avalan" Falkiewicz <avalatron@gmail.com>
# Contributor: C Anthony Risinger <anthony@xtfx.me>

pkgbase=python-ply
pkgname=(python-ply python2-ply)
pkgver=3.10
pkgrel=1
pkgdesc='Implementation of lex and yacc parsing tools'
arch=('any')
url='http://www.dabeaz.com/ply/'
license=('BSD')
makedepends=('python-setuptools' 'python2-setuptools')
source=("${url}ply-$pkgver.tar.gz"
        LICENSE)
sha256sums=('96e94af7dd7031d8d6dd6e2a8e0de593b511c211a86e28a9c9621c275ac8bacb'
            '87c20dd0a774f4d4ff837b4f1555f7eb1ed1b8dc1e3223cd105e5c1e282d62bf')

prepare() {
  cp -a ply-$pkgver{,-py2}
}

check() {
  cd "ply-$pkgver/test"
  python testlex.py
  python testyacc.py

  cd "$srcdir/ply-$pkgver-py2/test"
  python2 testlex.py
  python2 testyacc.py
}

package_python-ply() {
  depends=('python')

  cd "ply-$pkgver"
  python setup.py install --root="$pkgdir"

  install -Dm644 ../LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

package_python2-ply() {
  depends=('python2')

  cd "ply-$pkgver-py2"
  python2 setup.py install --root="$pkgdir"

  install -Dm644 ../LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

# vim:set ts=2 sw=2 et:
